home *** CD-ROM | disk | FTP | other *** search
/ CDUTIL 13 / CDUTIL #13 Julio 1995.iso / windows / acadcom / ads / sample / calerr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-08  |  7.8 KB  |  174 lines

  1. /* Next available MSG number is    66 */
  2.  
  3. /*****************************************************************************
  4.       CALERR.C
  5.       (C) Copyright 1988-1994 by Autodesk, Inc.
  6.  
  7.       This program is copyrighted by Autodesk, Inc. and is  licensed
  8.       to you under the following conditions.  You may not distribute
  9.       or  publish the source code of this program in any form.   You
  10.       may  incorporate this code in object form in derivative  works
  11.       provided  such  derivative  works  are  (i.) are  designed and 
  12.       intended  to  work  solely  with  Autodesk, Inc. products, and 
  13.       (ii.)  contain  Autodesk's  copyright  notice  "(C)  Copyright  
  14.       1988-1993 by Autodesk, Inc."
  15.  
  16.       AUTODESK  PROVIDES THIS PROGRAM "AS IS" AND WITH  ALL  FAULTS.
  17.       AUTODESK  SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF  MER-
  18.       CHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,  INC.
  19.       DOES  NOT  WARRANT THAT THE OPERATION OF THE PROGRAM  WILL  BE
  20.       UNINTERRUPTED OR ERROR FREE.
  21.  
  22.   Description: Error reporting function for the Geometry Calculator ADS
  23.                application.
  24.  
  25.       CAUTION: the corresponding xmf file has been build manualy and
  26.                the message numbers correspond to the positions of
  27.            the strings in the error_messages structure. So if
  28.            you add, remove or modify theses messages, please
  29.            update the xmf file.
  30.  
  31. *****************************************************************************/
  32.  
  33.  
  34. /****************************************************************************/
  35. /*  INCLUDES                                                                */
  36. /****************************************************************************/
  37.  
  38. #define MODULE_ID CALERR_C_
  39.  
  40. #include "cal.h"
  41.  
  42. #include "xmf.h"
  43. #include "ads_ix.h"
  44.  
  45.  
  46. /****************************************************************************/
  47. /*  EXPORTED VARIABLES                                                      */
  48. /****************************************************************************/
  49.  
  50. int cal_err;                          /* Error number, 0 means O.K. */
  51.  
  52.  
  53. /****************************************************************************/
  54. /*  STATIC VARIABLES                                                        */
  55. /****************************************************************************/
  56.  
  57. static char *error_messages[] =
  58. {
  59.    "%s",                                                            /* 0*/
  60.    /*MSG0*/"Wrong real number '%s'",                                        /* 1*/
  61.    /*MSG0*/"Illegal character '%s'",
  62.    /*MSG0*/"Integer numbers must be between -32768 and 32767",
  63.    /*MSG0*/"Function %s requires one argument",
  64.    /*MSG0*/"Right parenthesis ')' missing",                                 /* 5*/
  65.    /*MSG0*/"Vector components must be real numbers",
  66.    /*MSG0*/"Wrong syntax of vector, maybe ',' missing",
  67.    /*MSG0*/"Wrong syntax of vector, maybe ']' missing",
  68.    /*MSG0*/"Unexpected end of expression",
  69.    /*MSG0*/"Wrong syntax of expression",                                    /*10*/
  70.    /*MSG0*/"Function %s requires vector argument",
  71.    /*MSG0*/"Function %s requires real argument",
  72.    /*MSG0*/"Argument to ASIN, ACOS must be between -1 and 1",
  73.    /*MSG0*/"Argument to ROUND and TRUNC must be between -32768 and 32767",
  74.    /*MSG0*/"Argument to SQRT cannot be negative",                           /*15*/
  75.    /*MSG0*/"Power operator '^' requires real operands",
  76.    /*MSG0*/"Negative numbers cannot be raised to real exponent",
  77.    /*MSG0*/"Division by 0",
  78.    /*MSG0*/"Operator '/' requires real-real or vector-real operands",
  79.    /*MSG0*/"Operator '&' requires vector operands",                         /*20*/
  80.    /*MSG0*/"Operators '+', '-' require operands of the same type",
  81.    /*MSG0*/"Invalid feet'-inches\" format",
  82.    /*MSG0*/"Numeric overflow",
  83.    /*MSG0*/"Function TANG does not accept arguments 90+k*180 degrees",
  84.    /*MSG0*/"Function %s takes no arguments",                                /*25*/
  85.    /*MSG0*/"Use %s",
  86.    /*MSG0*/"The calculator expression must be a string",
  87.    /*MSG0*/"Assignment operator '=' used improperly",
  88.    /*MSG0*/"Failed to assign the value of the expression to variable %s",
  89.    /*MSG0*/"The 2D vector for NOR(v) function has zero length",             /*30*/
  90.    /*MSG0*/"AutoLISP symbol '%s ...' is too long",
  91.    /*MSG0*/"Unknown AutoCAD system variable %s",
  92.    /*MSG0*/"Only real, integer or point AutoCAD system variables accepted",
  93.    /*MSG0*/"Angles should be written in <deg>d<min>'<sec>\" format",
  94.    /*MSG0*/"Wrong syntax of point (vector)",                                /*35*/
  95.    /*MSG0*/"Point 'p' in ANG(apex,p1,p2,p) function lies on plane (apex,p1,p2)",
  96.    /*MSG0*/"Points in ANG(apex,p1,p2,p) function coincide",
  97.    /*MSG0*/"Function %s requires positive argument",
  98.    /*MSG0*/"The 2D points in ANG(p1,p2) function coincide",
  99.    /*MSG0*/"The two points defining line in function %s coincide",          /*40*/
  100.    /*MSG0*/"Integer value of expression is not between -32768 and 32767",
  101.    /*MSG0*/"The function name %s is not an identifier",
  102.    /*MSG0*/"Value of AutoLISP variable %s must be a point, real or integer",
  103.    /*MSG0*/"Too many calculator functions",
  104.    /*MSG0*/"AutoLISP variable %s has no value",                             /*45*/
  105.    /*MSG0*/"Null function name or function pointer to cal_register_function()",
  106.    /*MSG0*/"Function name %s is too long",
  107.    /*MSG0*/"The point to be rotated lies on the axis of rotation",
  108.    /*MSG0*/"Comma expected in argument list of function %s",
  109.    /*MSG0*/"Too many arguments to function %s",                             /*50*/
  110.    /*MSG0*/"The points in NOR(p1,p2,p3) function coincide or are collinear",
  111.    /*MSG0*/"Function %s doesn't exist",
  112.    /*MSG0*/"The points 'p1ax' and 'p2ax' in ROT(p,p1ax,p2ax,angle) coincide",
  113.    /*MSG0*/"The two lines in function %s do not intersect or are collinear",
  114.    /*MSG0*/"The line is parallel to the plane",                             /*55*/
  115.    /*MSG0*/"The 2D vector in ANG(v) function is zero length",
  116.    /*MSG0*/"The 2D points in ANG(apex,p1,p2) function coincide",
  117.    /*MSG0*/"The points 'p1' and 'p2' in function PLD(dist,p1,p2) coincide",
  118.    /*MSG0*/"The three points defining the plane are coincident or collinear",
  119.    /*MSG0*/"Function %s was already registered",                            /*60*/
  120.    /*MSG0*/"The two 2D points defining line in %s function coincide",
  121.    /*MSG0*/"The line lies on the plane",
  122.    /*MSG0*/"Use CVUNIT(value,from_units,to_units)",
  123.    /*MSG0*/"CVUNIT failed to convert units",
  124. };
  125.  
  126.  
  127. /****************************************************************************/
  128. /*.doc error(external)*/
  129. /*+
  130.   Error reporting function. 'n' is the error number, 'str' is an additional 
  131.   string argument which is printed only in some error messages. 
  132.  
  133.   If the error number 'n' is 0, then the string 'str' is printed 
  134.   instead of a message from the 'error_messages' array.
  135.  
  136.   The function does nothing if 'cal_err' is already non-zero, avoiding 
  137.   chained error messages.
  138. -*/
  139. /****************************************************************************/
  140.  
  141.  
  142. void
  143. /*FCN*/error(n, str)
  144.  
  145.   int  n;                             /* Error number                       */
  146.   char *str;                          /* Additional string to print or NULL */
  147. {
  148.     cal_lex.sym = no_sym;
  149.  
  150.     if (cal_err != 0)
  151.         return;
  152.  
  153.     if (n != 0) {
  154.         cal_err = n;
  155.     } else {
  156.         cal_err = -999;
  157.         if (str == NULL)
  158.             return;                   /* Just assign cal_err = -999 */
  159.     }
  160.     
  161.     if (str == NULL) 
  162.         str = "";
  163.  
  164.     ads_printf(XMSG("\n>> Error: ", 65));
  165.     if ((cal_err < 0) || (cal_err >= ELEMENTS(error_messages))) {
  166.         ads_printf("%d\n\n", cal_err);
  167.     } else {
  168.         ads_printf(XMSG(error_messages[cal_err], cal_err), str);
  169.         ads_printf(".\n\n");
  170.     }
  171. } /*error*/
  172.  
  173.  
  174.